/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.zyao89.view.zloading.slice;

import com.zyao89.view.zloading.ResourceTable;
import com.zyao89.view.zloading.Z_TYPE;
import com.zyao89.view.zloading.adapter.ShowViewAdapter;

import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.ListContainer;
import ohos.multimodalinput.event.TouchEvent;

import java.util.ArrayList;
import java.util.List;

/**
 * 功能描述
 *
 * @author jjy
 * @since 2021-03-22
 */
public class ShowTimeAllAbilitySlice extends AbilitySlice {
    private static final int MLINE_SIZE = 6;
    private ListContainer mRecyclerView;

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        setUIContent(ResourceTable.Layout_ability_show_time);
        initView();
    }

    private void initView() {
        List<Integer> lines = new ArrayList<>();
        for (int index = 0; index < MLINE_SIZE; index++) {
            lines.add(index);
        }
        mRecyclerView = (ListContainer) findComponentById(ResourceTable.Id_show_list_container);
        ShowViewAdapter sampleItemProvider = new ShowViewAdapter(lines, this);
        sampleItemProvider.setTypes(Z_TYPE.values());
        mRecyclerView.setItemProvider(sampleItemProvider);
        mRecyclerView.setTouchEventListener(new Component.TouchEventListener() {
            @Override
            public boolean onTouchEvent(Component component, TouchEvent touchEvent) {
                return true;
            }
        });
        mRecyclerView.setLongClickable(false);
        mRecyclerView.setReboundEffect(false);
    }
}
